import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

class User implements Comparable<User> {
	private int age;

	public User(int age) {
		this.age = age;
	}

	public int getAge() {
		return age;
	}

	@Override
	public int compareTo(User o) {

		return age - o.age;
	}

	@Override
	public String toString() {
		return "User [age=" + age + "]";
	}

}

class StuUser extends User {
	private String no;

	public StuUser(int age, String no) {
		super(age);
		this.no = no;
	}

	public String getNo() {
		return no;
	}

	@Override
	public String toString() {
		return "StuUser [no=" + no + ", toString()=" + super.toString() + "]";
	}

}

class UserReverseComparator implements Comparator<User> {

	@Override
	public int compare(User o1, User o2) {
		return o2.getAge() - o1.getAge();
	}

}

class StuUserComparator implements Comparator<StuUser> {

	@Override
	public int compare(StuUser o1, StuUser o2) {
		return o1.getNo().compareTo(o2.getNo());
	}


public static <T extends Comparable>T max(List<T> list){
	list.sort((Comparator<? super T>) list);
	return list.get(list.size());
}


public class GenericMain {
	public void main(String[] args) {
		List<Integer> list=new ArrayList<Integer>();
		list.add(3);
		list.add(2);
		list.add(5);
		System.out.println(max(list));
		List<String> strlist=new ArrayList<String>();
		strlist.add("a");
		strlist.add("b");
		strlist.add("f");
		System.out.println(max(list));
	}
}
}
